<template>
	<view class="usdt-withdraw-page">
		<view class="withdraw-input">
			<text>提现地址：</text>
			<input v-model="withdrawAddress" type="text" placeholder="请输入提现地址" />
			<button @click="scanAddress">扫码</button>
		</view>

		<view class="network-selection">
			<text>转账主网：</text>
			<radio-group v-model="selectedNetwork">
				<label v-for="(network, index) in networkTypes" :key="index">
					<radio :value="network.value" /> {{ network.label }}
				</label>
			</radio-group>
		</view>

		<view class="withdraw-amount">
			<text>提现数量：</text>
			<input v-model="withdrawAmount" type="number" placeholder="请输入提现数量" />
			<button @click="withdrawAll">全部提现</button>
		</view>
		<view>
			<label>可用</label>
			<view>0.231USDT</view>
		</view>
		<view></view>


		<view>
			<view>
				<label>到账数量</label>
				<view><text>0.0</text>USDT</view>
				<view><view>网络手续费</view>0.0 USDT</view>
			</view>
			<button class="withdraw-btn" @click="confirmWithdraw" disabled="!withdrawEnable">确认提现</button>
		</view>

		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				withdrawAddress: '', // 提现地址
				selectedNetwork: 'ETH', // 默认选择的转账主网
				networkTypes: [{
						label: 'ETH',
						value: 'ETH'
					},
					{
						label: 'TRON',
						value: 'TRON'
					},
					// 可根据需要添加其他主网类型
				],
				withdrawAmount: '',// 提现数量
				withdrawEnable :false,
			};
		},
		methods: {
			scanAddress() {
				// 调用扫码功能获取提现地址
				uni.scanCode({
					success: res => {
						this.withdrawAddress = res.result;
					},
					fail: () => {
						uni.showToast({
							title: '扫码失败',
							icon: 'none'
						});
					}
				});
			},
			withdrawAll() {
				// 在此处获取用户账户的总余额，然后将总余额设置为提现数量
				const totalBalance = 1000; // 这里模拟用户账户的总余额
				this.withdrawAmount = totalBalance.toString();
			},
			confirmWithdraw() {
				// 处理确认提现的逻辑
				console.log('确认提现');
				console.log('提现地址:', this.withdrawAddress);
				console.log('转账主网:', this.selectedNetwork);
				console.log('提现数量:', this.withdrawAmount);
				// 在这里进行提现操作，调用接口或其他操作
			}
		}
	};
</script>

<style scoped>
	/* 样式可根据实际需求进行调整 */
	.usdt-withdraw-page {
		padding: 20px;
	}

	.withdraw-input,
	.network-selection,
	.withdraw-amount {
		display: flex;
		align-items: center;
		margin-bottom: 20px;
	}

	input {
		flex: 1;
		padding: 8px;
		margin-right: 10px;
	}

	button {
		padding: 8px 16px;
		border-radius: 5px;
	}

	.withdraw-btn {
		width: 100%;
		padding: 10px;
		background-color: #007bff;
		color: #fff;
		border: none;
		border-radius: 5px;
	}
</style>